package 字符串;

/**
 * @author mubei
 * @date 2021/12/14
 * @description
 */
public class Demo03 {


    public String replaceSpaces(String S, int length) {
        StringBuilder builder = new StringBuilder();
        char[] chars = S.toCharArray();
        for (int i = 0; i < length; i++) {
            if (chars[i]==' '){
                chars[i]='%';
            }
            builder.append(chars[i]);
        }
        String s = builder.toString();
        return s.replace("%","%20");
    }

}
